Skip to content

Conversation

@Veritania
Copy link

This change introduces "StartServerInAdminOnlyMode": true/false as a key in the data/perpetuum.ini file.

If it's set to true, the server will start up with the RelayState.OpenForAdminsOnly state.
This state can then be changed during runtime, by logging in on an admin game account and doing #relayopen or #relayclose. This will not edit the perpetuum.ini file, only the currently running state.

If the StartServerInAdminOnlymode key is missing from the .ini file, we default to false - Meaning the server will start up with RelayState.OpenForPublic

The already merged PR #290 + this PR = Closes #257
Test:

  • Set "StartServerInAdminOnlyMode": true in the .ini file
  • Start server
  • Login with a regular player account
    • Expect: Error - relay closed to public
  • Login with admin player account
  • do #secure and #relayopen in a chat
  • Attempt to login with a regular player account
    • Expect: Succesful login

Sanity:

  • Set "StartServerInAdminOnlyMode": false (or alternatively, remove the StartServerInAdminOnlyMode key completely)
  • Start server
  • Login with a regular player account
    • Expect: Succesful login

@Veritania Veritania added the enhancement New feature or request label Apr 4, 2021
@Veritania Veritania self-assigned this Apr 4, 2021
@Veritania Veritania mentioned this pull request Apr 4, 2021
@MikeJeffers
Copy link

We don't use the admin too since we launch with a windows service, we would edit and set the ini file directly before or after startup.
In the server core the ini is read in to initialize a GlobalConfiguration object. It might be a bit tricky to get the relay to use this in the bootstrapper but should be possible.

@Veritania
Copy link
Author

The changes in the admin tool is mostly just "cosmetic" to improve log output, and can be removed entirely if you wish. It's not coupled with the actual feature.

In the server core the ini is read in to initialize a GlobalConfiguration object. It might be a bit tricky to get the relay to use this in the bootstrapper but should be possible.

I'm not sure I understand your suggestion. You'd like for the RelayStateService to be initialized with the value from the .ini config in the bootstrapper, instead of the propsed changes?

@MikeJeffers
Copy link

I'm not sure I understand your suggestion. You'd like for the RelayStateService to be initialized with the value from the .ini config in the bootstrapper, instead of the propsed changes?

Sorry, no was reading things too quickly and needed to remind myself how the ini inits the GlobalConfig. I see how you are using it in the relaystate to initialize it with its value on startup with the info builder. all good

Copy link

@MikeJeffers MikeJeffers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, just realized what was actually happening between the server and admintool reading of the ini file.


private bool GetAdminOnlyModeFromIni(string gameRoot)
{
var perpetuumIni = Path.Combine(gameRoot, PERPETUUMINIFILE);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only nit I'll put here is that the ini file should be read once, by one service, so there is no potential for split/conflicting state to occur.
A very edge-y case for something that is just for logging on a tool we don't use, but still something to consider.

Problem becomes exposing things to the admin tool - and maybe thats messier or causes more violations of design principles.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry I meant to leave this in the original review, but didn't commit the comment :( )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, good catch! It's bad practice and should be pointed out.

20f674e refactors it, so we read the file once and put the values into a dictionary - and then read the values from the dict instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes this, but I also mean that the server itself reads the ini file for GlobalConfig <- that's where the server's copy of this data resides.
TBD if it actually bad/nasty to expose this object to something like a client like the Admintool. I suspect yes, so I'm cool if basically we assume the state of the ini file will not change between Admintool and server boot

@Veritania Veritania merged commit 5e314a6 into Development Apr 8, 2021
@MikeJeffers MikeJeffers deleted the issue-257-startup-server-in-dev-only-mode branch April 9, 2021 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request P21

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dev-only mode

2 participants